package com.tuling.code.jdk8.lambda;

public class FunctionTester {
	public static void main(String[] args) {
		//jdk8之前的做法
		FunInterface demo = new FunInterface(){

			@Override
			public String teach(String content) {
				return "张飞老师教："+content;
			}
			
		};
		System.out.println(demo.teach("java 8 新特性"));
		
		//jdk8之后的lambda表达式
		
		FunInterface demo2 = (content) -> {return "张小飞老师教："+content;};
		System.out.println(demo2.teach("java 8 新特性"));
	
		FunInterface demo3 = (a) -> "张菲菲教："+a;
		System.out.println(demo3.teach("高级java8特性"));
		
		FunInterface demo4 = String :: valueOf;
		System.out.println(demo4.teach("高级java8特性"));
		
		
		//单行：
		FunInterface f1 = (a) -> a;
		System.out.println(f1.teach("hahah"));
		
		//多行  {};
		FunInterface f2 = (content) ->{
			content = content.toUpperCase();
			return "张飞老师教："+content;
		};
		System.out.println(f2.teach("java虚拟机"));
		
		//表达式
		FunInterface f3 = (a) -> "张菲菲教："+a;
		System.out.println(f3.teach("Hello world"));
	}
}
